#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

//以普通函数的形式定义一个匹配规则
bool mycomp1(int i, int j)
{
    return (i % j == 0);
}

//以函数的对象的形式定义一个匹配规则
class mycomp2
{
public:
    bool operator()(const int &i, const int &j)
    {
        return (i % j == 0);
    }
};

int main()
{
    vector<int> myvector{1, 2, 3, 4, 8, 12, 18, 1, 2, 3};
    int myarr[] = {1, 2, 3};
    //调用第一种语法格式
    vector<int>::iterator it = find_end(myvector.begin(), myvector.end(), myarr, myarr + 3);
    if (it != myvector.end())
    {
        cout << "last{1,2,3}: " << it - myvector.begin() << " ,*it = " << *it << endl;
    }

    int myarr2[] = {2, 4, 6};
    it = find_end(myvector.begin(), myvector.end(), myarr2, myarr2 + 3, mycomp2());
    if (it != myvector.end())
    {
        cout << "last{2,3,4}: " << it - myvector.begin() << " ,*it = " << *it;
    }

    return 0;
}